import axios from 'axios'
import {getToken} from "@/utils/auth"

const token = getToken()

const request = axios.create({
    baseURL: import.meta.env.VITE_APP_API_URL,
    timeout: 5000
})

request.interceptors.request.use((config) => {
    if (token) {
        config.headers.Authorization = token
    }
    return config
})

request.interceptors.response.use((response) => {
    if (response.data.code !== 200) {
    } else {
        return response.data
    }
}, (error) => {
})

export default request
